import { createRouter, createWebHistory } from 'vue-router'

import checkLogin from './hooks/checkLogin'

const name = '张三'

const router = createRouter({
  // import.meta.env.BASE_URL 它的值为 / 可以不写在方法中ss
  // history: createWebHistory(import.meta.env.BASE_URL),
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('../views/HomeView.vue')
    },
    {
      path: '/about',
      name: 'about',
      component: () => import('../views/AboutView.vue')
    },
    {
      // 动态路由参数
      path: '/detail/:id',
      name: 'detail',
      component: () => import('../views/DetailVue.vue')
    },
    {
      path: '/login',
      component: () => import('../views/LoginView.vue')
    }
  ]
})

// 定义全局导航守卫
// router.beforeEach(checkLogin)
router.beforeEach(checkLogin(name))

export default router


// 创建git分支
// git branch 名称
// git checkout -b 名称

// any/unknown 区别
// never类型的作用
